
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<style type="text/css">

body{
    margin: 0 auto;
    font-family: "ubuntu", "Tahoma", "Microsoft YaHei", arial,sans-serif;
    color: #444444;
    line-height: 1;
    padding: 30px;
}

img {
    max-width: 100%;
}

@media screen and (min-width: 1000px) {
    body {
        width: 842px;
        margin: 10px auto;
    }

    
}

h1, h2, h3, h4 {
    color: #111111;
    font-weight: 400;
    margin-top: 1em;
}

h1, h2, h3, h4, h5 {
	font-family: Georgia, Palatino, serif;
}

h1, h2, h3, h4, h5, dl{
    margin-top: 16px;
    margin-bottom: 16px;
    padding: 0;
}

p {
    margin-top: 8px;
    margin-bottom: 3px;
}

h1 {
    font-size: 30px;
    line-height: 54px;
}

h2 {
    font-size: 24px;
    line-height: 42px;
}
h1, h2 {
    border-bottom: 1px solid #EFEAEA;
    padding-bottom: 10px;
}

h3 {
    font-size: 18px;
    line-height: 30px;
}

h4 {
    font-size: 15px;
    line-height: 26px;
}
h5 {
    font-size: 12px;
    line-height: 23px;
}

a {
    color: #0099ff;
    margin: 0 2px;
    padding: 0;
    vertical-align: baseline;
    text-decoration: none;
}

a:hover {
    text-decoration: none;
    color: #ff6600;
}

a:visited {
    /*color: purple;*/
}

ul, ol {
    padding: 0;
    padding-left: 18px;
    margin: 0;
}

li {
    line-height: 24px;
}

p, ul, ol {
    font-size: 16px;
    line-height: 24px;
}

ol ol, ul ol {
    list-style-type: lower-roman;
}

code, pre {
    font-family: Consolas, Monaco, Andale Mono, monospace;
    background-color:#f7f7f7;
    color: inherit;
}

code {
    font-family: Consolas, Monaco, Andale Mono, monospace;
    margin: 0 2px;
}

pre {
    font-family: Consolas, Monaco, Andale Mono, monospace;
    line-height: 1.7em;
    overflow: auto;
    padding: 6px 10px;
    border-left: 5px solid #6CE26C;
}

pre > code {
    font-family: Consolas, Monaco, Andale Mono, monospace;
    border: 0;
    display: inline;
    max-width: initial;
    padding: 0;
    margin: 0;
    overflow: initial;
    line-height: 1.6em;
    font-size: .95em;
    white-space: pre;
    background: 0 0;

}

code {
    color: #666555;
}

aside {
    display: block;
    float: right;
    width: 390px;
}

blockquote {
    border-left:.5em solid #eee;
    padding: 0 0 0 2em;
    margin-left:0;
}

blockquote  cite {
    font-size:14px;
    line-height:20px;
    color:#bfbfbf;
}

blockquote cite:before {
    content: '\2014 \00A0';
}

blockquote p {
    color: #666;
}

hr {
    text-align: left;
    color: #999;
    height: 2px;
    padding: 0;
    margin: 16px 0;
    background-color: #e7e7e7;
    border: 0 none;
}

dl {
    padding: 0;
}

dl dt {
    padding: 10px 0;
    margin-top: 16px;
    font-size: 1em;
    font-style: italic;
    font-weight: bold;
}

dl dd {
    padding: 0 16px;
    margin-bottom: 16px;
}

dd {
    margin-left: 0;
}

table {
    *border-collapse: collapse; /* IE7 and lower */
    border-spacing: 0;
    width: 100%;
}

table {
    border: solid #ccc 1px;
}

table thead {
    background: #f7f7f7;
}

table thead tr:hover {
    background: #f7f7f7
}

table tr:hover {
    background: #fbf8e9;
    -o-transition: all 0.1s ease-in-out;
    -webkit-transition: all 0.1s ease-in-out;
    -moz-transition: all 0.1s ease-in-out;
    -ms-transition: all 0.1s ease-in-out;
    transition: all 0.1s ease-in-out;
}

table td, .table th {
    border-left: 1px solid #ccc;
    border-top: 1px solid #ccc;
    padding: 10px;
    text-align: left;
    min-width: 80px;
}

table th {
    border-top: none;
    text-shadow: 0 1px 0 rgba(255,255,255,.5);
    padding: 5px;
    border-left: 1px solid #ccc;
}

table td:first-child, table th:first-child {
    border-left: none;
}
</style>
<h1>规则 Bugfinder-1.1</h1>
<h2>常规信息</h2>
<table>
<thead>
<tr>
<th style="text-align: left;">项目</th>
<th style="text-align: center;">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">规则文本</td>
<td style="text-align: center;">内部变量隐藏了同名的外部变量。</td>
</tr>

<tr>
<td style="text-align: left;">规则等级</td>
<td style="text-align: center;">必要</td>
</tr>
<tr>
<td style="text-align: left;">分析范围</td>
<td style="text-align: center;">单元</td>
</tr>
<tr>
<td style="text-align: left;">语言标准</td>
<td style="text-align: center;">Java</td>
</tr>
<tr>
<td style="text-align: left;">性能表现</td>
<td style="text-align: center;">中速</td>
</tr>
</tbody>
</table>
<h2>规则释义</h2>






<p>如果特定范围（如内部类或方法定义）声明的名称（如成员变量或参数）与封闭范围中的另一个声明相同，则特定范围的声明将隐藏（shadow）封闭范围的声明。即遵循局部优先原则。</p>
<p>特别地，匿名类除了没有名字外，其它和局部类并没有什么不同。如果没有特殊说明，自然也隐性地包含了匿名类。</p>
<p><strong>修复或避错建议：</strong><br/></p>
<p>修改变量名为不同的名字。</p>
<h2>例外情况</h2>



<p>如果是方法形参与类属性（或从父类继承）同名，则很多时候只是为了给成员变量赋值，由于这种情况很普遍，故对于这类情况不做检查。</p>
<h2>测试样例</h2>
<h3>Testfile Bugfinder_1_1.java</h3>
<pre><code class="language-java">public class Bugfinder_1_1 extends Foo {
    private String name;
    private int age;
    private String department;  // noncompliant

    public InnerVariableHideOuterVariableCase(String name, int age, String jobNo) {
        super(jobNo);
        this.name = name;
        this.age = age;
    }

    public boolean overAge() {
        int age = 18;  // noncompliant
        String jobNo = "No.20202384723";  // noncompliant
        return false;
    }
}

public class Foo {
    protected String jobNo;
    protected String department;
    public Foo(String jobNo, String department) {
        this.jobNo = jobNo;
        this.department = department;
    }
}
</code></pre>

